<?php
/*
    +--------------------------------------------------------------------------
    |   iProber v1.0.0 beta
    |   ========================================
    |   by Tahiti
    |   dEpoch Studio
    |   http://www.depoch.net
    |   ========================================
    |   Web: http://www.depoch.net
    |   Last Updated: 29th April 2006
    |   Email: depoch@gmail.com
    +---------------------------------------------------------------------------
    |
    |   > PHP PROBER
    |   > Script written by Tahiti

    |
    +--------------------------------------------------------------------------
*/

	header("content-Type: text/html; charset=UTF-8");
    error_reporting(E_ERROR | E_WARNING | E_PARSE);
     
    $valInt = (false == empty($_POST['pInt']))?$_POST['pInt']:"未测试";
    $valFloat = (false == empty($_POST['pFloat']))?$_POST['pFloat']:"未测试";
    $valIo = (false == empty($_POST['pIo']))?$_POST['pIo']:"未测试";
    $mysqlReShow = "none";
    $mailReShow = "none";
    $funReShow = "none";
    $opReShow = "none";
    $sysReShow = "none";
     
    define("YES", "<span class='resYes'>YES</span>");
    define("NO", "<span class='resNo'>NO</span>");
    define("ICON", "<span class='icon'>2</span>&nbsp;");
    $phpSelf = $_SERVER[PHP_SELF] ? $_SERVER[PHP_SELF] : $_SERVER[SCRIPT_NAME];
    define("PHPSELF", preg_replace("/(.{0,}?\/+)/", "", $phpSelf));

	global $loadedExtensions;
	$loadedExtensions=get_loaded_extensions();
	$commonExtensions=array('Zend Optimizer','eAccelerator','session','pcre','mysql','gd','xml','curl','iconv','mbstring','calendar','bcmath','SQLite','sqlite','pgsql','sockets','ftp','mhash','mcrypt','zlib','soap','standard','PDO','pdo_mysql','pdo_sqlite','SimpleXML','mysqli','odbc');
     
    if ($_GET['act'] == "phpinfo")
    {
        phpinfo();
        exit();
    }
    elseif($_POST['act'] == "TEST_1")
    {
        $valInt = test_int();
    }
    elseif($_POST['act'] == "TEST_2")
    {
        $valFloat = test_float();
    }
    elseif($_POST['act'] == "TEST_3")
    {
        $valIo = test_io();
    }
    elseif($_POST['act'] == "CONNECT")
    {
        $mysqlReShow = "show";
        $mysqlRe = "MYSQLl连接测试结果";
        $mysqlRe .= (false !== @mysql_connect($_POST['mysqlHost'], $_POST['mysqlUser'], $_POST['mysqlPassword']))?"MYSQL服务器连接正常, ":
        "MYSQL服务器连接失败, ";
        $mysqlRe .= "数据库 <b>".$_POST['mysqlDb']."</b> ";
        $mysqlRe .= (false != @mysql_select_db($_POST['mysqlDb']))?"连接正常":"连接失败";
    }
    elseif($_POST['act'] == "SENDMAIL")
    {
        $mailReShow = "show";
        $mailRe = "MAIL邮件发送测试结果：发送";
        $mailRe .= (false !== @mail($_POST["mailReceiver"], "MAIL SERVER TEST", "This email is sent by iProber.\r\n\r\ndEpoch Studio\r\nhttp://www.depoch.net"))?"完成":"失败";
    }
    elseif($_POST['act'] == "FUNCTION_CHECK")
    {
        $funReShow = "show";
        $funRe = "函数 <b>".$_POST['funName']."</b> 支持状况检测结果：".(false!==function_exists($_POST['funName'])?YES:NO);
    }
    elseif($_POST['act'] == "CONFIGURATION_CHECK")
    {
        $opReShow = "show";
        $opRe = "配置参数 <b>".$_POST['opName']."</b> 检测结果：".getcon($_POST['opName']);
    }
     
     
    // 系统参数
     
     
    switch (PHP_OS)
    {
        case "Linux":
        $sysReShow = (false !== ($sysInfo = sys_linux()))?"show":"none";
        break;
        case "FreeBSD":
        $sysReShow = (false !== ($sysInfo = sys_freebsd()))?"show":"none";
        break;
		case "WINNT";
		$sysReShow = (false !== ($sysInfo = sys_win()))?"show":"none";
        default:
        break;
    }


     
/*========================================================================*/
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>PHP探针 iProber V0.024</title>
<meta name="keywords" content="php探针,探针程序,php探针程序,探针,iProber,dEpoch Studio" />
<style type="text/css">
<!--
body,div,p,ul,form,h1 { margin:0px; padding:0px; }
body { background:#252724; }
div,a,input { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; color:#7D795E; }
div { margin-left:auto; margin-right:auto; width:720px; }
input { border: 1px solid #414340; background:#353734; }
a,#t3 a.arrow,#f1 a.arrow { text-decoration:none; color:#978F78; }
a:hover { text-decoration:underline; }
a.arrow { font-family:Webdings, sans-serif; color:#343525; font-size:10px; }
a.arrow:hover { color:#ff0000; text-decoration:none; }
.resYes { font-size: 9px; font-weight: bold; color: #33CC00; } 
.resNo { font-size: 9px; font-weight: bold; color: #CC3300; }
.myButton { font-size:10px; font-weight:bold;  background:#3D3F3E; border:1px solid #4A4C49; border-right-color:#2D2F2C; border-bottom-color:#2D2F2C; color:#978F78; }
.bar { border:1px solid #2D2F2C; background:#6C6754; height:8px; font-size:2px; }
.bar li { background:#979179; height:8px; font-size:2px; list-style-type:none; }
table { clear:both; background:#2D2F2C; border:3px solid #41433E; margin-bottom:10px; }
td,th { padding:4px; background:#363835; }
th { background:#7E7860; color:#343525; text-align:left; }
th span { font-family:Webdings, sans-serif; font-weight:normal; padding-right:4px; }
th p { float:right; line-height:10px; text-align:right; }
th a { color:#343525; }
h1 { color:#009900; font-size:35px; width:300px; float:left; }
h1 b { color:#cc3300; font-size:50px; font-family: Webdings, sans-serif; font-weight:normal; }
h1 span { font-size:10px; padding-left:10px; color:#7D795E;  }
#t12 { float:right; text-align:right; padding:15px 0px 30px 0px; }
#t12 a { line-height:18px; color:#7D795E; }
#t3 td{ line-height:30px; height:30px; text-align:center; background:#3D3F3E; border:1px solid #4A4C49; border-right:none; border-bottom:none; }
#t3 th,#t3 th a { font-weight:normal; }
#m4 td {text-align:center;}
.th2 th,.th3 { background:#232522; text-align:center; color:#7D795E; font-weight:normal;  }
.th3 { font-weight:bold; text-align:left; }
#footer table { clear:none; }
#footer td { text-align:center; padding:1px 3px; font-size:9px; }
#footer a { font-size:9px; }
#f1 { text-align:right; padding:15px; }
#f2 {float:left; border:1px solid #dddddd; }
#f2 td { background:#FF6600; }
#f2 a { color:#ffffff; }
#f3 { border: 1px solid #888888; float:right; }
#f3 a { color:#222222; }
#f31 { background:#2359B1; color:#FFFFFF; }
#f32 { background:#dddddd; }
-->
</style>
</head>
<body>
<form method="post" action="<?php echo PHPSELF;?>#bottom">
	<div>
		<input type="hidden" name="pInt" value="<?php echo $valInt;?>" />
		<input type="hidden" name="pFloat" value="<?php echo $valFloat;?>" />
		<input type="hidden" name="pIo" value="<?php echo $valIo;?>" />
<!-- =============================================================
页头
============================================================= -->
		<h1><i><b>i</b>Prober</i><span>V1.0.0 Beta</span></h1>
		<a name="top"></a>
		<p id="t12">
			<a href="http://www.depoch.net/download.htm" target="_blank">点击下载 iProber 探针, 或查看最新版本 </a>
			■<br />
			<a href="mailto:depoch@depoch.net">报告BUGS, 或反馈意见给 dEpoch Studio </a>
			■
		</p>
		<table width="100%" border="0" cellspacing="1" cellpadding="0" id="t3">
			<tr>
				<td><a href="#sec1">服务器特征</a></td>
				<td><a href="#sec2">PHP基本特征</a></td>
				<td><a href="#sec3">PHP组件支持状况</a></td>
				<td><a href="#sec4">服务器性能检测</a></td>
				<td><a href="#sec5">自定义检测</a></td>
				<td><a href="<?=PHPSELF?>" class="t211">刷新</a></td>
				<td><a href="#bottom" class="arrow">66</a></td>
			</tr>
			<tr>
				<th colspan="8"><b>〖AD〗</b>
					<a href="http://www.egobiz.com" target="_blank">羿高域名商务网: </a>
					<a href="http://www.egobiz.com/domain/" target="_blank">域名注册</a>
					<a href="http://www.egobiz.com/domain-sell/" target="_blank">域名交易</a>
					<a href="http://www.egobiz.com/deleting-domain/" target="_blank">过期域名|删除域名查询</a>
					<a href="http://www.egobiz.com/domain-tool/" target="_blank">域名工具集</a></th>
			</tr>
		</table>
<!-- =============================================================
服务器特性
============================================================= -->
		<table width="100%" border="0" cellspacing="1" cellpadding="0">
			<tr>
				<th colspan="2"><p>
						<a href="#top" class="arrow">5</a>
						<br />
						<a href="#bottom" class="arrow">6</a>
					</p>
					<span>8</span>服务器特性
					<a name="sec1" id="sec1"></a>
				</th>
			</tr>
			<?php if("show"==$sysReShow){?>
			<tr>
				<td>服务器处理器 CPU</td>
				<td>CPU个数：
					<?php echo $sysInfo['cpu']['num'];?>
					<br />
					<?php echo $sysInfo['cpu']['detail'];?></td>
			</tr>
			<?php }?>
			<tr>
				<td>服务器时间</td>
				<td><?php echo date("Y年n月j日 H:i:s");?>
					&nbsp;北京时间
					<?php echo gmdate("Y年n月j日 H:i:s",time()+8*3600);?></td>
			</tr>
			<?php if("show"==$sysReShow){?>
			<tr>
				<td>服务器运行时间</td>
				<td><?php echo $sysInfo['uptime'];?></td>
			</tr>
			<?php }?>
			<tr>
				<td>服务器域名/IP地址</td>
				<td><?php echo $_SERVER['SERVER_NAME'];?>
					(
					<?php echo @gethostbyname($_SERVER['SERVER_NAME']);?>
					)</td>
			</tr>
			<tr>
				<td>服务器操作系统
					<?php $os = explode(" ", php_uname());?></td>
				<td>
					<?php echo $os[0]."&nbsp;".$os[1];
					if("show"==$sysReShow) echo "<br />内核版本：".$sysInfo['OSCore']."&nbsp;&nbsp;发行版本".$sysInfo['OSName'];
					?>
				</td>
			</tr>
			<tr>
				<td>主机名称</td>
				<td><?php echo $os[2];?></td>
			</tr>
			<tr>
				<td>服务器解译引擎</td>
				<td><?php echo $_SERVER['SERVER_SOFTWARE'];?></td>
			</tr>
			<tr>
				<td>Web服务端口</td>
				<td><?php echo $_SERVER['SERVER_PORT'];?></td>
			</tr>
			<tr>
				<td>服务器管理员</td>
				<td><a href="mailto:<?php echo $_SERVER['SERVER_ADMIN'];?>">
					<?php echo $_SERVER['SERVER_ADMIN'];?>
					</a></td>
			</tr>
			<tr>
				<td>本文件路径</td>
				<td><?php echo $_SERVER['PATH_TRANSLATED'];?></td>
			</tr>
			<tr>
				<td>目前还有空余空间&nbsp;diskfreespace</td>
				<td><?php echo number_format((@disk_free_space(".")/(1024*1024)),2);?>
					M</td>
			</tr>
			<?php if("show"==$sysReShow){?>
			<tr>
				<td>内存使用状况</td>
				<td>物理内存：共
					<?php echo $sysInfo['memTotal'];?>
					M, 已使用
					<?php echo $sysInfo['memUsed'];?>
					M, 空闲
					<?php echo $sysInfo['memFree'];?>
					M, 使用率
					<?php echo $sysInfo['memPercent'];?>
					%
					<?php echo bar($sysInfo['memPercent']);?>
					SWAP区，共：
					<?php echo $sysInfo['swapTotal'];?>
					M, 已使用
					<?php echo $sysInfo['swapUsed'];?>
					M, 空闲
					<?php echo $sysInfo['swapFree'];?>
					M, 使用率
					<?php echo $sysInfo['swapPercent'];?>
					%
					<?php echo bar($sysInfo['swapPercent']);?>
				</td>
			</tr>
			<tr>
				<td>系统平均负载</td>
				<td><?php echo $sysInfo['loadAvg'];?></td>
			</tr>
			<?php }?>
		</table>
<?php if(false!== function_exists("apache_get_modules")){
$commonModules=array('core','prefork','worker','mod_rewrite','mod_vhost_alias','mod_gzip','mod_deflate','mod_autoindex','mod_include');
$loadedModules=apache_get_modules();
?>
<!-- ============================================================= 
APACHE模块
============================================================== -->
<table width="100%" cellpadding="0" cellspacing="1" border="0">
			<tr>
				<th colspan="4"><p>
						<a href="#top" class="arrow">5</a>
						<br />
						<a href="#bottom" class="arrow">6</a>
					</p>
					<span>8</span>APACHE模块
				</th>
			</tr>
			<tr class="th2"><th colspan="4">常用模块</th></tr>
			<tr>
				<td>prefork: 非线程式MPM</td>
				<td><?php echo is_loaded2("prefork");?></td>
				<td>worker: 线程式MPM</td>
				<td><?php echo is_loaded2("worker");?></td>
			</tr>
			<tr>
				<td>mod_deflate: 内容压缩(Apache 2.x)</td>
				<td><?php echo is_loaded2("mod_deflate");?></td>
				<td>mod_gzip: 内容压缩(Apache 1.x)</td>
				<td><?php echo is_loaded2("mod_gzip");?></td>
			</tr>
			<tr>
				<td>mod_rewrite: URL重写</td>
				<td><?php echo is_loaded2("mod_rewrite");?></td>
				<td>mod_vhost_alias: 虚拟主机动态配置</td>
				<td><?php echo is_loaded2("mod_vhost_alias");?></td>
			</tr>
			<tr>
				<td>mod_autoindex: 目录内容自动列表</td>
				<td><?php echo is_loaded2("mod_autoindex");?></td>
				<td>mod_include: 服务器端包含(SSI)</td>
				<td><?php echo is_loaded2("mod_include");?></td>
			</tr>
			<tr class="th2"><th colspan="4">已加载的其他模块</th></tr>
			<tr><td colspan="4"><?php echo join(", ",array_diff($loadedModules,$commonModules));?></td></tr>
<?php }?>
<!-- ============================================================= 
PHP基本特性
============================================================== -->
		<table width="100%" cellpadding="0" cellspacing="1" border="0">
			<tr>
				<th colspan="2"><p>
						<a href="#top" class="arrow">5</a>
						<br />
						<a href="#bottom" class="arrow">6</a>
					</p>
					<span>8</span>PHP基本特性
					<a name="sec2" id="sec2"></a>
				</th>
			</tr>
			<tr>
				<td width="49%">PHP运行方式</td>
				<td width="51%"><?php echo strtoupper(php_sapi_name());?></td>
			</tr>
			<tr>
				<td>PHP版本</td>
				<td><?php echo PHP_VERSION;?></td>
			</tr>
			<tr>
				<td>运行于安全模式</td>
				<td><?php echo getcon("safe_mode");?></td>
			</tr>
			<tr>
				<td>允许使用URL打开文件&nbsp;allow_url_fopen</td>
				<td><?php echo getcon("allow_url_fopen");?></td>
			</tr>
			<tr>
				<td>允许动态加载链接库&nbsp;enable_dl</td>
				<td><?php echo getcon("enable_dl");?></td>
			</tr>
			<tr>
				<td>显示错误信息&nbsp;display_errors</td>
				<td><?php echo getcon("display_errors");?></td>
			</tr>
			<tr>
				<td>自动定义全局变量&nbsp;register_globals</td>
				<td><?php echo getcon("register_globals");?></td>
			</tr>
			<tr>
				<td>程序最多允许使用内存量&nbsp;memory_limit</td>
				<td><?php echo getcon("memory_limit");?></td>
			</tr>
			<tr>
				<td>POST最大字节数&nbsp;post_max_size</td>
				<td><?php echo getcon("post_max_size");?></td>
			</tr>
			<tr>
				<td>允许最大上传文件&nbsp;upload_max_filesize</td>
				<td><?php echo getcon("upload_max_filesize");?></td>
			</tr>
			<tr>
				<td>程序最长运行时间&nbsp;max_execution_time</td>
				<td><?php echo getcon("max_execution_time");?>秒</td>
			</tr>
			<tr>
				<td>magic_quotes_gpc</td>
				<td><?php echo (1===get_magic_quotes_gpc())?YES:NO;?></td>
			</tr>
			<tr>
				<td>magic_quotes_runtime</td>
				<td><?php echo (1===get_magic_quotes_runtime())?YES:NO;?></td>
			</tr>
			<tr>
				<td>被禁用的函数&nbsp;disable_functions</td>
				<td><?php echo (""==($disFuns=get_cfg_var("disable_functions")))?"无":str_replace(",","<br />",$disFuns);?></td>
			</tr>
			<tr>
				<td>PHP信息&nbsp;PHPINFO</td>
				<td><?php echo (false!==eregi("phpinfo",$disFuns))?NO:"<a href='$phpSelf?act=phpinfo' target='_blank' class='static'>PHPINFO</a>";?></td>
			</tr>
		</table>
<!-- ============================================================= 
PHP扩展
============================================================== -->
		<table width="100%" cellpadding="0" cellspacing="1" border="0">
			<tr>
				<th colspan="4"><p>
						<a href="#top" class="arrow">5</a>
						<br />
						<a href="#bottom" class="arrow">6</a>
					</p>
					<span>8</span>PHP扩展
					<a name="sec3" id="sec3"></a>
				</th>
			</tr>
			<tr class="th2"><th colspan="4">常用扩展</th></tr>
			<tr>
				<td>Zend Optimizer: PHP编译运行/优化</td>
				<td><?php echo is_loaded("Zend Optimizer");?></td>
				<td>eAccelerator：加速/缓存</td>
				<td><?php echo is_loaded("eAccelerator");?></td>
			</tr>
			<tr>
				<td>Session会话</td>
				<td><?php echo is_loaded("session");?></td>
				<td>PCRE: Perl兼容正则表达式</td>
				<td><?php echo is_loaded("pcre");?></td>
			</tr>
            <tr>
				<td>GD图形处理</td>
				<td><?php echo is_loaded("gd");?></td>
                <td>PDO PHP数据对象</td>
				<td><?php echo is_loaded("PDO");?></td>
            </tr>
            <tr>
				<td>MySQL数据库</td>
				<td><?php echo is_loaded("mysql");?></td>
                <td>SQLite数据库</td>
				<td><?php echo is_loaded(array("SQLite","sqlite"));?></td>
			</tr>
            <tr>
				<td>PDO_MYSQL MySQL的PDO驱动</td>
				<td><?php echo is_loaded("pdo_mysql");?></td>
				<td>PDO_SQLITE SQLite的PDO驱动</td>
				<td><?php echo is_loaded("pdo_sqlite");?></td>
			</tr>
	        <tr>
				<td>MySQLi</td>
				<td><?php echo is_loaded("mysqli");?></td>
				<td>PostgreSQL数据库</td>
				<td><?php echo is_loaded("pgsql");?></td>
			</tr>		
			<tr>
				<td>XML解析</td>
				<td><?php echo is_loaded("xml");?></td>
				<td>SimpleXML</td>
				<td><?php echo is_loaded("SimpleXML");?></td>
			</tr>
			<tr>
				<td>iconv</td>
				<td><?php echo is_loaded("iconv");?></td>
				<td>mbstring</td>
				<td><?php echo is_loaded("mbstring");?></td>
			</tr>			
			<tr>
				<td>Calendar: 历法运算</td>
				<td><?php echo is_loaded("calendar");?></td>
				<td>BCMath: 高精度数学运算</td>
				<td><?php echo is_loaded("bcmath");?></td>
			</tr>
			<tr>
                <td>CURL: 客户端URL</td>
				<td><?php echo is_loaded("curl");?></td>
                <td>ODBC</td>
				<td><?php echo is_loaded("odbc");?></td>
			</tr>
			<tr>
				<td>Socket</td>
				<td><?php echo is_loaded("sockets");?></td>
				<td>FTP</td>
				<td><?php echo is_loaded("ftp");?></td>
			</tr>
			<tr>
				<td>Mhash哈稀计算</td>
				<td><?php echo is_loaded("mhash");?></td>
				<td>MCrypt加密方法</td>
				<td><?php echo is_loaded("mcrypt");?></td>
			</tr>
			<tr>
				<td>zlib压缩</td>
				<td><?php echo is_loaded("zlib");?></td>
				<td>SOAP: 简单对象访问协议</td>
				<td><?php echo is_loaded("soap");?></td>
			</tr>
			<tr class="th2"><th colspan="4">已加载的其他扩展</th></tr>
			<tr><td colspan="4"><?php echo join(", ",array_diff($loadedExtensions,$commonExtensions));?></td></tr>
		</table>
<!-- ============================================================= 
服务器性能检测
============================================================== -->
		<table width="100%" cellpadding="0" cellspacing="1" border="0" id="m4">
			<tr>
				<th colspan="4"><p>
						<a href="#top" class="arrow">5</a>
						<br />
						<a href="#bottom" class="arrow">6</a>
					</p>
					<span>8</span>服务器性能检测
					<a name="sec4" id="sec4"></a>
				</th>
			</tr>
			<tr class="th2" >
				<th>检测对象</th>
				<th>整数运算能力测试<br />
					(1+1运算300万次)</th>
				<th>浮点运算能力测试<br />
					(开平方300万次)</th>
				<th>数据I/O能力测试<br />
					(读取10K文件10000次)</th>
			</tr>
			<tr>
				<td>Tahiti 的电脑(P4 1.7G 256M WinXP)</td>
				<td> 1.421秒</td>
				<td> 1.358秒</td>
				<td> 0.177秒</td>
			</tr>
			<tr>
				<td>PIPNI免费空间(2004/06/28 02:08)</td>
				<td> 2.545秒</td>
				<td> 2.545秒</td>
				<td>0.171秒 </td>
			</tr>
			<tr>
				<td>神话科技风CGI型(2004/06/28 02:03)</td>
				<td> 0.797秒</td>
				<td> 0.729秒</td>
				<td>0.156秒</td>
			</tr>
			<tr>
				<td>您正在使用的这台服务器</td>
				<td><b>
					<?php echo $valInt;?>
					</b><br />
					<input type="submit" value="TEST_1" class="myButton"  name="act" /></td>
				<td><b>
					<?php echo $valFloat;?>
					</b><br />
					<input type="submit" value="TEST_2" class="myButton"  name="act" /></td>
				<td><b>
					<?php echo $valIo;?>
					</b><br />
					<input type="submit" value="TEST_3" class="myButton"  name="act" /></td>
			</tr>
		</table>
<!-- ============================================================= 
自定义检测 
============================================================== -->
<?php
    $isMysql = (false !== function_exists("mysql_query"))?"":" disabled";
    $isMail = (false !== function_exists("mail"))?"":" disabled";
?>
		<table width="100%" border="0" cellspacing="1" cellpadding="0">
			<tr>
				<th colspan="4"><p>
						<a href="#top" class="arrow">5</a>
						<br />
						<a href="#bottom" class="arrow">6</a>
					</p>
					<span>8</span>自定义检测
					<a name="sec5" id="sec6"></a>
				</th>
			</tr>
			<tr>
				<th colspan="4" class="th3">MYSQLl连接测试</th>
			</tr>
			<tr>
				<td>MYSQL服务器</td>
				<td><input type="text" name="mysqlHost" value="localhost" <?php echo $isMysql;?> /></td>
				<td> MYSQL用户名</td>
				<td><input type="text" name="mysqlUser" <?php echo $isMysql;?> /></td>
			</tr>
			<tr>
				<td> MYSQL密码</td>
				<td><input type="text" name="mysqlPassword" <?php echo $isMysql;?> /></td>
				<td> MYSQL数据库名称</td>
				<td><input type="text" name="mysqlDb" />
					&nbsp;<input type="submit" class="myButton" value="CONNECT" <?php echo $isMysql;?>  name="act" /></td>
			</tr>
			<?php if("show"==$mysqlReShow){?>
			<tr>
				<td colspan="4"><?php echo $mysqlRe;?></td>
			</tr>
			<?php }?>
			<tr>
				<th colspan="4" class="th3">MAIL邮件发送测试</th>
			</tr>
			<tr>
				<td>收信地址</td>
				<td colspan="3"><input type="text" name="mailReceiver" size="50" <?php echo $isMail;?> />
					&nbsp;<input type="submit" class="myButton" value="SENDMAIL" <?php echo $isMail;?>  name="act" /></td>
			</tr>
			<?php if("show"==$mailReShow){?>
			<tr>
				<td colspan="4"><?php echo $mailRe;?></td>
			</tr>
			<?php }?>
			<tr>
				<th colspan="4" class="th3">函数支持状况</th>
			</tr>
			<tr>
				<td>函数名称</td>
				<td colspan="3"><input type="text" name="funName" size="50" />
					&nbsp;<input type="submit" class="myButton" value="FUNCTION_CHECK" name="act" /></td>
				<?php if("show"==$funReShow){?>
			<tr>
				<td colspan="4"><?php echo $funRe;?></td>
			</tr>
			<?php }?>
			</tr>
			
			<tr>
				<th colspan="4" class="th3">PHP配置参数状况</th>
			</tr>
			<tr>
				<td>参数名称</td>
				<td colspan="3"><input type="text" name="opName" size="40" />
					&nbsp;<input type="submit" class="myButton" value="CONFIGURATION_CHECK" name="act" /></td>
			</tr>
			<?php if("show"==$opReShow){?>
			<tr>
				<td colspan="4"><?php echo $opRe;?></td>
			</tr>
			<?php }?>
		</table>
<!-- ============================================================= 
页脚 
============================================================== -->
		<div id="footer">
			<p id="f1">
				<a name="bottom"></a>
				<a href="#top" class="arrow">55</a>
			</p>
			<table  border="0" cellspacing="1" cellpadding="0" id="f2">
				<tr>
					<td><a href="http://validator.w3.org/check?uri=referer" target="_blank">XHTML</a></td>
					<td><a href="http://jigsaw.w3.org/css-validator/validator?uri=http://<?php echo $_SERVER['SERVER_NAME'].($_SERVER[PHP_SELF] ? $_SERVER[PHP_SELF] : $_SERVER[SCRIPT_NAME]);;?>" target="_blank">CSS</a>
					</td>
				</tr>
			</table>
			<table  border="0" cellspacing="1" cellpadding="0" id="f3">
				<tr>
					<td id="f31">Powered by</td>
					<td id="f32"><a href="http://www.depoch.net"><b>dEpoch Studio</b></a>
					</td>
				</tr>
			</table>
		</div>
	</div>
</form>
</body>
</html>
<?php
/*=============================================================
    函数库
=============================================================*/
/*-------------------------------------------------------------------------------------------------------------
    PHP扩展加载检测
--------------------------------------------------------------------------------------------------------------*/
    function is_loaded($extensionName)
    {
        global $loadedExtensions;
		if(false!==is_array($extensionName))
		{
			foreach($extensionName as $ext)
			{
				if(false!==in_array($ext,$loadedExtensions)) return YES;
			}
			return NO;
		}
		return (false!==in_array($extensionName,$loadedExtensions))?YES:NO;
    }
/*-------------------------------------------------------------------------------------------------------------
    APACHE模块加载检测
--------------------------------------------------------------------------------------------------------------*/
    function is_loaded2($moduleName)
    {
        global $loadedModules;
		return (false!==in_array($moduleName,$loadedModules))?YES:NO;
    }
/*-------------------------------------------------------------------------------------------------------------
    PHP设置参数检测
--------------------------------------------------------------------------------------------------------------*/
    function getcon($varName)
    {
	   switch($res=get_cfg_var($varName))
        {
            case "0":
			case "";
            return NO;
            break;
            case "1":
            return YES;
            break;
            default:
            return $res;
            break;
        }
    }
/*-------------------------------------------------------------------------------------------------------------
    整数运算能力测试
--------------------------------------------------------------------------------------------------------------*/
    function test_int()
    {
        $timeStart = gettimeofday();
        for($i = 0; $i < 3000000; $i++);
        {
            $t = 1+1;
        }
        $timeEnd = gettimeofday();
        $time = ($timeEnd["usec"]-$timeStart["usec"])/1000000+$timeEnd["sec"]-$timeStart["sec"];
        $time = round($time, 3)."秒";
        return $time;
    }
/*-------------------------------------------------------------------------------------------------------------
     浮点运算能力测试
--------------------------------------------------------------------------------------------------------------*/
    function test_float()
    {
        $t = pi();
        $timeStart = gettimeofday();
        for($i = 0; $i < 3000000; $i++);
        {
            sqrt($t);
        }
        $timeEnd = gettimeofday();
        $time = ($timeEnd["usec"]-$timeStart["usec"])/1000000+$timeEnd["sec"]-$timeStart["sec"];
        $time = round($time, 3)."秒";
        return $time;
    }
/*-------------------------------------------------------------------------------------------------------------
    数据IO能力测试
--------------------------------------------------------------------------------------------------------------*/
    function test_io()
    {
        $fp = fopen(__FILE__, "r");
        $timeStart = gettimeofday();
        for($i = 0; $i < 10000; $i++)
        {
            fread($fp, 10240);
            rewind($fp);
        }
        $timeEnd = gettimeofday();
        fclose($fp);
        $time = ($timeEnd["usec"]-$timeStart["usec"])/1000000+$timeEnd["sec"]-$timeStart["sec"];
        $time = round($time, 3)."秒";
        return($time);
    }
/*-------------------------------------------------------------------------------------------------------------
    比例条
--------------------------------------------------------------------------------------------------------------*/
    function bar($percent)
    {
    ?>
		<ul class="bar">
			<li style="width:<?=$percent?>%">&nbsp;</li>
		</ul>
<?php
    }
/*-------------------------------------------------------------------------------------------------------------
    系统参数探测 LINUX
--------------------------------------------------------------------------------------------------------------*/
    function sys_linux()
    {
        // CPU
        if (false === ($str = @file("/proc/cpuinfo"))) return false;
        $str = implode("", $str);
        @preg_match_all("/model\s+name\s{0,}\:+\s{0,}([^\r\n]+)[\r\n]+/", $str, $model);
        @preg_match_all("/cache\s+size\s{0,}\:+\s{0,}([\d\.]+\s{0,}[A-Z]+[\r\n]+)/", $str, $cache);
        if (false !== is_array($model[1]))
            {
            $res['cpu']['num'] = sizeof($model[1]);
            for($i = 0; $i < $res['cpu']['num']; $i++)
            {
                $res['cpu']['detail'][] = "类型：".$model[1][$i]." 缓存：".$cache[1][$i];
            }
            if (false !== is_array($res['cpu']['detail'])) $res['cpu']['detail'] = implode("<br />", $res['cpu']['detail']);
            }
         
         
        // UPTIME
        if (false === ($str = @file("/proc/uptime"))) return false;
        $str = explode(" ", implode("", $str));
        $str = trim($str[0]);
        $res['uptime']=get_uptime($str);
         
        // MEMORY
        if (false === ($str = @file("/proc/meminfo"))) return false;
        $str = implode("", $str);
        preg_match_all("/MemTotal\s{0,}\:+\s{0,}([\d\.]+).+?MemFree\s{0,}\:+\s{0,}([\d\.]+).+?SwapTotal\s{0,}\:+\s{0,}([\d\.]+).+?SwapFree\s{0,}\:+\s{0,}([\d\.]+)/s", $str, $buf);
         
        $res['memTotal'] = number_format($buf[1][0]/1024, 2);
        $res['memFree'] = number_format($buf[2][0]/1024, 2);
        $res['memUsed'] = ($res['memTotal']-$res['memFree']);
        $res['memPercent'] = (floatval($res['memTotal'])!=0)?round($res['memUsed']/$res['memTotal']*100,2):0;
         
        $res['swapTotal'] = number_format($buf[3][0]/1024, 2);
        $res['swapFree'] = number_format($buf[4][0]/1024, 2);
        $res['swapUsed'] = ($res['swapTotal']-$res['swapFree']);
        $res['swapPercent'] = (floatval($res['swapTotal'])!=0)?round($res['swapUsed']/$res['swapTotal']*100,2):0;
         
        // LOAD AVG
        if (false === ($str = @file("/proc/loadavg"))) return false;
        $str = explode(" ", implode("", $str));
        $str = array_chunk($str, 3);
        $res['loadAvg'] = implode(" ", $str[0]);
         
        return $res;
    }
/*-------------------------------------------------------------------------------------------------------------
    系统参数探测 FreeBSD
--------------------------------------------------------------------------------------------------------------*/
    function sys_freebsd()
    {
        //CPU
        if (false === ($res['cpu']['num'] = get_key("hw.ncpu"))) return false;
        $res['cpu']['detail'] = get_key("hw.model");
         
        //LOAD AVG
        if (false === ($res['loadAvg'] = get_key("vm.loadavg"))) return false;
        $res['loadAvg'] = str_replace("{", "", $res['loadAvg']);
        $res['loadAvg'] = str_replace("}", "", $res['loadAvg']);
         
        //UPTIME
        if (false === ($buf = get_key("kern.boottime"))) return false;
        $buf = explode(' ', $buf);
        $sys_ticks = time() - intval($buf[3]);
        $res['uptime']=get_uptime($sys_ticks);
         
        //MEMORY
        if (false === ($buf = get_key("hw.physmem"))) return false;
        $res['memTotal'] = number_format($buf/1024/1024, 2);
        $buf = explode("\n", do_command("vmstat", ""));
        $buf = explode(" ", trim($buf[2]));
         
        $res['memFree'] = number_format($buf[5]/1024, 2);
        $res['memUsed'] = ($res['memTotal']-$res['memFree']);
        $res['memPercent'] = (floatval($res['memTotal'])!=0)?round($res['memUsed']/$res['memTotal']*100,2):0;
		         
        $buf = explode("\n", do_command("swapinfo", "-k"));
        $buf = $buf[1];
        preg_match_all("/([0-9]+)\s+([0-9]+)\s+([0-9]+)/", $buf, $bufArr);
        $res['swapTotal'] = number_format($bufArr[1][0]/1024, 2);
        $res['swapUsed'] = number_format($bufArr[2][0]/1024, 2);
        $res['swapFree'] = number_format($bufArr[3][0]/1024, 2);
        $res['swapPercent'] = (floatval($res['swapTotal'])!=0)?round($res['swapUsed']/$res['swapTotal']*100,2):0;
         
        return $res;
    }
     
/*-------------------------------------------------------------------------------------------------------------
    取得参数值 FreeBSD
--------------------------------------------------------------------------------------------------------------*/
function get_key($keyName)
    {
        return do_command('sysctl', "-n $keyName");
    }
     
/*-------------------------------------------------------------------------------------------------------------
    确定执行文件位置 FreeBSD
--------------------------------------------------------------------------------------------------------------*/
    function find_command($commandName)
    {
        $path = array('/bin', '/sbin', '/usr/bin', '/usr/sbin', '/usr/local/bin', '/usr/local/sbin');
        foreach($path as $p)
        {
            if (@is_executable("$p/$commandName")) return "$p/$commandName";
        }
        return false;
    }
     
/*-------------------------------------------------------------------------------------------------------------
    执行系统命令 FreeBSD
--------------------------------------------------------------------------------------------------------------*/
    function do_command($commandName, $args)
    {
        $buffer = "";
        if (false === ($command = find_command($commandName))) return false;
        if ($fp = @popen("$command $args", 'r'))
            {
				while (!@feof($fp))
				{
					$buffer .= @fgets($fp, 4096);
				}
				return trim($buffer);
			}
        return false;
    }
/*-------------------------------------------------------------------------------------------------------------
    系统参数探测 WINNT
--------------------------------------------------------------------------------------------------------------*/
function sys_win()
{
	if(!$com=@new COM("WbemScripting.SWbemLocator")) return false;
	if(!$obj=@$com->ConnectServer()) return false;

	$res=false;
	
	// memory
	$buf=get_win_prop($obj,"Win32_LogicalMemoryConfiguration",array("TotalPhysicalMemory"));
	$res['memTotal']=number_format($buf[0]['TotalPhysicalMemory']/1024,2);
	$buf=get_win_prop($obj,"Win32_PerfFormattedData_PerfOS_Memory", array("AvailableKBytes"));
	$res['memFree']=number_format($buf[0]['AvailableKBytes']/1024,2);
	$res['memUsed'] = ($res['memTotal']-$res['memFree']);
    $res['memPercent'] = (floatval($res['memTotal'])!=0)?round($res['memUsed']/$res['memTotal']*100,2):0;
	
	// cpu
	$buf=get_win_prop($obj,"Win32_Processor",array( "Name", "L2CacheSize"));
	if(false!==is_array($buf)&&@count($buf)>0)
	{
		$res['cpu']['num']=@count($buf);
		$res['cpu']['detail']=""; $sep="";
		foreach($buf as $t)
		{
			$res['cpu']['detail'].="类型：".$t['Name']."&nbsp;缓存：".$t['L2CacheSize']." KB";
			$sep="<br />";
		}
	}

	// uptime
	$buf=get_win_prop($obj,"Win32_OperatingSystem",array( "LastBootUpTime", "LocalDateTime" ));
	if(($bTime=$buf[0]['LastBootUpTime'])&&($cTime=$buf[0]['LocalDateTime']))
	{
		$secs=mktime(intval(substr($cTime,8,2)),intval(substr($cTime,10,2)),intval(substr($cTime,12,2)),intval(substr($cTime,4,2)),intval(substr($cTime,6,2)),intval(substr($cTime,0,4)))-mktime(intval(substr($bTime,8,2)),intval(substr($bTime,10,2)),intval(substr($bTime,12,2)),intval(substr($bTime,4,2)),intval(substr($bTime,6,2)),intval(substr($bTime,0,4)));
        $res['uptime'] =get_uptime($secs);
	}

	// load average
	$buf=get_win_prop($obj,"Win32_Processor",array("LoadPercentage" ));
	$res['loadAvg']=$buf[0]['LoadPercentage'];

	// core version
	$buf=get_win_prop($obj,"Win32_OperatingSystem", array("Version", "ServicePackMajorVersion"));
	$res['OSCore']=$buf[0]['Version'];
	if(floatval($buf[0]['ServicePackMajorVersion'])>0) $res['OSCore'].="&nbsp;SP".$buf[0]['ServicePackMajorVersion'];
	
	// distribution version
	$buf=get_win_prop($obj,"Win32_OperatingSystem", array("Caption"));
	$res['OSName']=$buf[0]['Caption'];

	return $res;
}
/*-------------------------------------------------------------------------------------------------------------
    取得系统参数值 WINNT
--------------------------------------------------------------------------------------------------------------*/
function get_win_prop($obj,$c,$ps)
{
	$raw=$obj->GET($c);

	if(false!==version_compare(PHP_VERSION,"5.0.0","<")) 
	{
		  $pObj = $raw->Properties_;
		  $props = $pObj->Next($pObj->Count);
		  $iObj = $raw->Instances_();
		  $items = $iObj->Next($iObj->Count);
	} 
	else 
	{
		  $props = $raw->Properties_;
		  $items = $raw->Instances_();
	}

	foreach($items as $item)
	{
		if(false!==is_array($ps)&&@count($ps)>0)
		{
			foreach($ps as $p)
			{
				$instance[$p]=trim($item->$p);
			}
		}
		$res[]=$instance;
	}
	return $res;
}
/*-------------------------------------------------------------------------------------------------------------
    生成在线时间
--------------------------------------------------------------------------------------------------------------*/
function get_uptime($secs)
{
	$min = $secs / 60;
	$hours = $min / 60;
	$days = floor($hours / 24);
	$hours = floor($hours - ($days * 24));
	$min = floor($min - ($days * 60 * 24) - ($hours * 60));
	if ($days !== 0) $res = $days."天";
	if ($hours !== 0) $res .= $hours."小时?";
	$res .= $min."分钟";
	return $res;
}
?>
